home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Miscellaneous / ival / ival.h < prev    next >
Text File  |  1987-05-25  |  7KB  |  267 lines

  1. /*
  2.  * ival.h - common declarations for the Interval Study program.
  3.  * Needs: quickdraw.h, window.h
  4.  * Owned by: ival.c
  5.  */
  6.  
  7. #define MYSIGN    ((long) 'BN34')    /* Interval's signature            */
  8. #define MYFILE    ((long) 'BN35')    /* Interval's files' signature (unused)    */
  9.  
  10. #define WINDOWID 260        /* Resource ID of my window    */
  11.  
  12. #define HMARGIN        15    /* min horz distance between objects    */
  13.  
  14. #define BUTTONFONT systemFont    /* font for control labels        */
  15. #define BUTPROCID     0    /* ProcID of a standard button        */
  16. #define RADPROCID     2    /* ProcID of a radio button        */
  17. #define BUTHEIGHT    19    /* height of a standard button        */
  18. #define BUTEXTRAH    20    /* non-name horz part of a button    */
  19. #define BUTVMARG     1    /* vertical margin between buttons    */
  20. #define BUTHMARG     5    /* horizontal margin between buttons    */
  21.  
  22. /*
  23.  * screenport - used to keep the current port from ever dangling.
  24.  *   This is a port for the whole screen.
  25.  */
  26.  
  27. #ifndef DATA
  28. extern
  29. #endif
  30. GrafPtr screenport;
  31.  
  32. #ifndef DATA
  33. extern
  34. #endif
  35. WindowPtr windoc;        /* the program's one window    */
  36.  
  37. /*
  38.  * *rect - bounds of the areas of the screen.
  39.  * Each area of the screen is described by one of the following rects:
  40.  *  cntlrect    - the Control area;
  41.  *  namerect    - the Name area;
  42.  *  noterect    - the Notation area.
  43.  */
  44.  
  45. #ifndef DATA
  46. extern Rect cntlrect;
  47. extern Rect namerect;
  48. extern Rect noterect;
  49. #else
  50. Rect cntlrect;
  51. Rect namerect;
  52. Rect noterect;
  53. #endif
  54.  
  55. /*
  56.  * scorerect - Rect enclosing the score.
  57.  * Scorerect lies completely within noterect.
  58.  */
  59.  
  60. #ifndef DATA
  61. extern
  62. #endif
  63. Rect scorerect;
  64.  
  65. /*
  66.  * progtasks, studtasks - booleans saying who provides what.
  67.  */
  68.  
  69. struct tasks {
  70.     short notate;    /* "provides notation"        */
  71.     short name;        /* "provides name"        */
  72.     short sound;    /* "provides sound"        */
  73. };
  74. #ifndef DATA
  75. extern struct tasks progtasks;    /* what the program provides    */
  76. extern struct tasks studtasks;    /* what the student provides    */
  77. #else
  78. struct tasks progtasks;
  79. struct tasks studtasks;
  80. #endif
  81.  
  82. /*
  83.  * acc_ok - accidentals are allowed.
  84.  */
  85.  
  86. #ifndef DATA
  87. extern
  88. #endif
  89. int acc_ok;
  90.  
  91. /*
  92.  * SEQ_* - how a sequence of tones are to be played:
  93.  * SEQ_HARM    - harmonic
  94.  * SEQ_MEL    - melodically
  95.  * SEQ_MIX    - a choice of harmonic or melodic.
  96.  */
  97.  
  98. #define SEQ_HARM    0
  99. #define SEQ_MEL        1
  100. #define NUM_SEQ        2    /* number of sequence values (0 or 1)    */
  101. #define SEQ_MIX        2
  102.  
  103. /*
  104.  * cur_seq - the way the current sequence of tones is to be played.
  105.  * One of SEQ_HARM or SEQ_MEL.
  106.  */
  107.  
  108. #ifndef DATA
  109. extern
  110. #endif
  111. int cur_seq;
  112.  
  113. /*
  114.  * any_seq - the way any sequence of tones is to be played.
  115.  * This value restricts the set of values for cur_seq.
  116.  * SEQ_HARM or SEQ_MEL means cur_seq can be only the value for any_seq;
  117.  * SEQ_MIX means cur_seq can be either.
  118.  */
  119.  
  120. #ifndef DATA
  121. extern
  122. #endif
  123. int any_seq;
  124.  
  125. /*
  126.  * *shown - TRUE if the corresponding thing is correctly displayed.
  127.  */
  128.  
  129. #ifndef DATA
  130. extern short tone1shown;    /* the second tone is drawn in the score */
  131. extern short isizeshown;    /* the interval size is correctly shown    */
  132. extern short itypeshown;    /* the interval type is correctly shown    */
  133.                 /* (up/down is always shown)        */
  134. #else
  135. short tone1shown;
  136. short isizeshown;
  137. short itypeshown;
  138. #endif
  139.  
  140. /*
  141.  * DEGPERSCORE, DEGPEROCT, OCTPERSCORE - definitions of the range of
  142.  *  representable tones.
  143.  *
  144.  * Degree 0 == Low C; Semitone 0 = Low C.
  145.  */
  146.  
  147. #define DEGPERSCORE    29    /* # of degrees in the score        */
  148. #define DEGPEROCT    7    /* # of degrees per octave        */
  149. #define OCTPERSCORE    (DEGPERSCORE / DEGPEROCT) /* octaves in the score*/
  150.  
  151. #define SEMPEROCT    12    /* semitones per octave            */
  152. #define NUMTONES    2    /* # of tones to place on the score    */
  153.  
  154. /*
  155.  * DEG_* - some interesting degrees of the scale
  156.  */
  157.  
  158. #define DEG_MIDC    14    /* middle C            */
  159. #define DEG_LOWF     3    /* F below Bass Clef        */
  160. #define DEG_HIGG    25    /* G above Treble Clef        */
  161.  
  162. /*
  163.  * IT_* - interval types (qualities)
  164.  */
  165.  
  166. #define IT_AUG         0    /* augmented    */
  167. #define IT_PERF         1    /* perfect    */
  168. #define IT_MAJ         2    /* major    */
  169. #define IT_MIN         3    /* minor    */
  170. #define IT_DIM         4    /* diminished    */
  171. #define IT_COUNT     5    /* number of IT_* items            */
  172.  
  173. /*
  174.  * ivinfo[] - table relating interval # of semitones and delta degrees
  175.  *   to its type.  A .semis value less than 0 ends the table.
  176.  */
  177.  
  178. struct ivinfo {
  179.     short semis;    /* number of semitones                */
  180.     short degs;        /* degrees in this interval (its isize)        */
  181.     short qual;        /* its quality (itype. E.g., IT_MAJ)        */
  182. };
  183. #ifndef DATA
  184. extern struct ivinfo ivinfo[];
  185. #else
  186. struct ivinfo ivinfo[] = {
  187.     {  0, 1 - 1, IT_PERF},    /* Perfect Unison        */
  188.     {  1, 1 - 1, IT_AUG},    /* Augmented Unison        */
  189.  
  190.     {  0, 2 - 1, IT_DIM},    /* Diminished 2nd        */
  191.     {  1, 2 - 1, IT_MIN},    /* Minor 2nd            */
  192.     {  2, 2 - 1, IT_MAJ},    /* Major 2nd            */
  193.     {  3, 2 - 1, IT_AUG},    /* Augmented 2nd        */
  194.  
  195.     {  2, 3 - 1, IT_DIM},    /* Diminished 3rd        */
  196.     {  3, 3 - 1, IT_MIN},    /* Minor 3rd            */
  197.     {  4, 3 - 1, IT_MAJ},    /* Major 3rd            */
  198.     {  5, 3 - 1, IT_AUG},    /* Augmented 3rd        */
  199.  
  200.     {  4, 4 - 1, IT_DIM},    /* Diminished 4th        */
  201.     {  5, 4 - 1, IT_PERF},    /* Perfect 4th            */
  202.     {  6, 4 - 1, IT_AUG},    /* Augmented 4th        */
  203.  
  204.     {  6, 5 - 1, IT_DIM},    /* Diminished 5th (tritone)    */
  205.     {  7, 5 - 1, IT_PERF},    /* Perfect 5th            */
  206.     {  8, 5 - 1, IT_AUG},    /* Augmented 5th        */
  207.  
  208.     {  7, 6 - 1, IT_DIM},    /* Diminished 6th        */
  209.     {  8, 6 - 1, IT_MIN},    /* Minor 6th            */
  210.     {  9, 6 - 1, IT_MAJ},    /* Major 6th            */
  211.     { 10, 6 - 1, IT_AUG},    /* Augmented 6th        */
  212.  
  213.     {  9, 7 - 1, IT_DIM},    /* Diminished 7th        */
  214.     { 10, 7 - 1, IT_MIN},    /* Minor 7th            */
  215.     { 11, 7 - 1, IT_MAJ},    /* Major 7th            */
  216.     { 12, 7 - 1, IT_AUG},    /* Augmented 7th        */
  217.  
  218.     { 11, 8 - 1, IT_DIM},    /* Diminished Octave        */
  219.     { 12, 8 - 1, IT_PERF},    /* Perfect Octave        */
  220.  
  221.     { -1, -1, -1}
  222. };
  223. #endif
  224.  
  225. /*
  226.  * curkey - the current key
  227.  */
  228.  
  229. struct akey {
  230.     short insharps;    /* TRUE= a key in sharps; FALSE= a key in flats    */
  231.     short number;    /* number of sharps/flats (0..DEGPEROCT)    */
  232. };
  233. #ifndef DATA
  234. extern
  235. #endif
  236. struct akey curkey;
  237.  
  238. /*
  239.  * curtone[] - the current tones being played/displayed.
  240.  */
  241.  
  242. struct atone {
  243.     short degree;    /* degrees above low C            */
  244.     short chrome;    /* chromatic adjustment (in semitones)    */
  245. };
  246. #define CH_FLAT    (-1)    /* a flat adjustment in atone.chrome    */
  247. #define CH_NAT      0    /* a natural "    "    "    "    */
  248. #define CH_SHARP  1    /* a sharp "    "    "    "    */
  249. #define NUM_CH      3    /* number of CH_* modifiers        */
  250.  
  251. #ifndef DATA
  252. extern
  253. #endif
  254. struct atone curtone[NUMTONES];
  255.  
  256. /*
  257.  * curitype, curisize - the current interval's size and type.
  258.  */
  259.  
  260. #ifndef DATA
  261. extern short curitype;
  262. extern short curisize;
  263. #else
  264. short curitype;
  265. short curisize;
  266. #endif
  267.